
import {Column, Entity, Index} from "typeorm";
import {BaseState} from "@/typing/state";
import {SupplierType} from "@/typing/supplierType";
import {BaseEntity} from "@/entitys/common/baseEntity";

export class BaseSupplierSpecification {
    @Column({comment: '规格'})
    specification: string;
    @Column({comment: '价格'})
    price: number;
    @Column({comment: '数量'})
    amount: number;
    @Column({comment: '币种'})
    currency: string;
}

@Index(["id"])
@Entity()
export class BaseSupplier<T = BaseSupplierSpecification> extends BaseEntity {
    
    @Column({comment: '供应商类型', type: 'enum', enum: SupplierType})
    supplierType: SupplierType;

    @Column({comment: '公司名称'})
    companyName: string;

    @Column({comment: '公司简称', nullable: true})
    companyAbbreviation: string;

    @Column({comment: '公司负责人'})
    representative: string;

    @Column({comment: '公司电话', nullable: true})
    phone: string;

    @Column({comment: '公司联系人'})
    contact: string;

    @Column({comment: '公司联系人电话'})
    contactPhone: string;

    @Column({comment: '公司地址', nullable: true})
    address: string;

    @Column({comment: '状态', type: 'enum', enum: BaseState, default: BaseState.enable})
    state: BaseState;

    @Column({comment: '规格类型', type: 'json'})
    specificationList: T[];
}